<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'home';
$return['ischecklogin']=cfc('core')->checklogin('','',true);
$this->model('member')->upmember();
$return['pluginset']['ailogo']=tomedia($return['pluginset']['ailogo']);
$return['basic']=$return['pluginset'];
if($_RQ['op']=='home'){
	if(!empty($_SESSION['openid'])){
		$openid = $_SESSION['openid'];
		$fansfollow=pdo_getcolumn('core_fans',array('uniacid'=>$_SESSION['uniacid'],'openid'=>$_SESSION['openid']),'follow');
	}
	$return['member']= $this->model('member')->getmember();
	$return['openid']= $_SESSION['openid'];
	$return['agent_group']=pdo_getall('jy_aiagent_agent_group',array('isshow'=>1,'uniacid'=>$_SESSION['uniacid']),array('id','title'),'id','paixu desc');
	foreach($return['agent_group'] as &$nv){
		
	}
	$return['params']=array('groupid'=>0);
	$return['post']=array('msg'=>'','issikao'=>1,'iswww'=>1);
	$return['sharedata']=array(
		'title'=>$return['basic']['share_title'],
		'desc'=>$return['basic']['share_desc'],
		'link'=>custom_url('jy_aiagent/index//fromuser='.$_SESSION['uid'],true),
		'imgUrl'=>ATTACHMENT_URL.$return['basic']['share_image'],
	);
	set_html('title','AI智能体广场');
	exi($return);
}
if($_RQ['op']=='getlist'){
	$params=array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']);
	$fields='';
	$orderby=array();
	$_RQ['page'] = $_RQ['page'] ? $_RQ['page'] : 1;
	$pindex = max(1, intval($_RQ['page']));
	if(intval($_RQ['num'])){
		$psize = intval($_RQ['num']);
	}else{
		$psize = 10;
	}
	$total='';
	$list=pdo_getslice('jy_aiagent_goodslog',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$item['goods']=pdo_get('jy_aiagent_goods',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['goodsid']));
			$item['goods']['image']=tomedia($item['goods']['image']);
			$item['agent']=pdo_get('jy_aiagent_useragent',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['agentid']));
			$item['agent']['logo']=tomedia($item['agent']['logo']);
			$item['alias']=$item['title'];
			$item['createtime']=date('Y/m/d H:i:s',$item['createtime']);
		}
	}
	$return['list']=$list?$list:array();
	exi($return);
}